<table class="table-content" cellspacing="0" cellpadding="0" >
    <col width="50px" />
    <col width="30px" />
    <col width="250px" />
    <col width="250px" />
    <col width="150px" />
    <col width="200px" />
    <col width="200px" />
    <tr class="table-header">
        <!--<th class="center" width="20px;">
        <input type="checkbox" name="test" onchange="checkAll()" id="checkAll"/>
        </th>-->
        <th>Comment</th>
        <th>Edit</th>
        <th>Tên</th>
        <th>Địa chỉ</th>
        <th>Tel</th>
        <th>Email</th>
        <th>Website</th>
    </tr>
    <?php foreach($this->result as $key=>$value){?>
        <tr>
            <td><a class="comment-button" href="/place/place-comment/index?place_id=<?php echo $value->place_id;?>"></a></td>
            <td><a class="edit-button" href="/place/place-edit/index?place_id=<?php echo $value->place_id;?>"></a></td>
            <td class="container"><div><?php echo $value->name ?></div></td>
            <td class="container"><div><?php echo $value->address ?></div></td>
            <td class="container"><div><?php echo $value->phone ?></div></td>
            <td class="container"><div><?php echo $value->mail ?></div></td>
            <td class="container"><div><?php echo $value->website ?></div></td>
            
        </tr>
    <?php } ?>
</table>
<div class="pagging">
    <a class="pagging-first" id="pagging-first" href="#" onclick="loadTable(1); return false;"></a>
    <a class="pagging-pre" id="pagging-pre" href="#"></a>
    <input class="pagging-seach" id="pagging-seach" value="<?php echo $this->page;?>"/><div class="pagging-info">of <?php echo $this->pageNumber; ?></div>
    <a class="pagging-next" id="pagging-next" href="#"></a>
    <a class="pagging-last" id="pagging-last" href="#" onclick="loadTable(<?php echo $this->pageNumber;?>); return false;" ></a>
</div>

<script>
    
    function loadMerchant(url,id){
        url = url + "?id="+id;
        window.location.replace(url);   
    }
    
    function loadTable(page){
        url = '/place/merchant-place/load-place' + "?page="+page;
        $("#pagging-seach").val(page);
        $("#table-place").load(url);
    }

    
    $(document).ready(function(){
        $("#pagging-pre").click(function(e){
            page = parseInt($("#pagging-seach").val());
            prev_page = page - 1;
            if(prev_page < 1){
                return false;
            }else{
                $("#pagging-seach").val(prev_page);
                
                if(prev_page > 0){
                    //$("#merchant-table").load('/place/merchant-place/load-place' + "?page="+prev_page);
                    $("#table-place").load('/place/merchant-place/load-place' + "?page="+prev_page);
                    return false;
                }
                
            }
        });
        
        $("#pagging-next").click(function(e){
            page = parseInt($("#pagging-seach").val());
            next_page = page + 1;
            if(next_page > <?php echo $this->pageNumber?>){
                return false;
            }else{
                
                $("#pagging-seach").val(next_page);
                //$("#merchant-table").load('/place/merchant-place/load-place' + "?page="+next_page);
                $("#table-place").load('/place/merchant-place/load-place' + "?page="+next_page);
                return false;
            }
        });
        
        $("#pagging-seach").keyup(function(event){
            if(event.keyCode == 13){
                page = $("#pagging-seach").val();
                if(page > 0 && page <= <?php echo $this->pageNumber?>){
                    $("#pagging-seach").val(page);
                    //$("#merchant-table").load('/place/merchant-place/load-place' + "?page="+page);
                    $("#table-place").load('/place/merchant-place/load-place' + "?page="+page);
                }else if(page <= 0){
                    //$("#merchant-table").load('/place/merchant-place/load-place');
                    $("#table-place").load('/place/merchant-place/load-place');
                    $("#pagging-seach").val(1);
                }else if(page > <?php echo $this->pageNumber?>){
                    $("#pagging-seach").val(<?php echo $this->pageNumber?>);
                    $("#table-place").load('/place/merchant-place/load-place' + "?page="+<?php echo $this->pageNumber?>);
                    //$("#merchant-table").load('/place/merchant-place/load-place' + "?page="+<?php echo $this->pageNumber?>);
                }
            }
        });
    });
</script>